<?php

namespace longhu\services\easywechat\listener;

use EasyWeChat\OfficialAccount\Message;
use think\facade\Log;

/**
 * 微信消息统一处理类
 */
class MessageListener
{
    public function __invoke(Message $message, \Closure $next)
    {
        Log::write($message->MsgType,'debug');
        try {
            return app()->make(MessageFacade::class)->make($message->MsgType)->send($message);
        }catch (\Exception $exception){
            return $next($message);
        }
    }

}